<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/fn"%>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<%@page import="com.abou.constant.product.*"%>
<%@ include file="../../constants.jsp"%>

<%-- The page URL --%>
<c:url var="pageUrl" value="/admin/product/modify.do" />

<c:if test="${not empty product}">

<%-- The search form --%>
<form:form id="productModifyForm" modelAttribute="product" cssClass="basic"
	name="productModifyForm" action="${pageUrl}" enctype="multipart/form-data">

	<%-- The global errors message --%>
	<jsp:include page="/WEB-INF/jsp/common/form/errors.jsp">
		<jsp:param name="code" value="form.errors" />
	</jsp:include>

	<fieldset class="classic">

	 	<legend><spring:theme code="field.product.legend.general"/></legend>

		<%-- The name field--%>
		<jsp:include page="/WEB-INF/jsp/common/form/form-field-text.jsp">
			<jsp:param name="code" value="field.product.name" />
			<jsp:param name="path" value="name" />
			<jsp:param name="focused" value="true" />
		</jsp:include>

		<%-- The price field--%>
		<jsp:include page="/WEB-INF/jsp/common/form/form-field-text.jsp">
			<jsp:param name="code" value="field.product.price" />
			<jsp:param name="path" value="price" />
		</jsp:include>

		<%-- The description field--%>
		<jsp:include page="/WEB-INF/jsp/common/form/form-field-limited-text-area.jsp">
			<jsp:param name="code" value="field.product.description" />
			<jsp:param name="path" value="description" />
			<jsp:param name="rows" value="5" />
			<jsp:param name="cols" value="23" />
			<jsp:param name="mandatory" value="true"/>
			<jsp:param name="limit" value="200"/>
			<jsp:param name="id" value="description"/>
		</jsp:include>

	</fieldset>

	<fieldset class="classic">

	 	<legend><spring:theme code="field.product.legend.images"/></legend>

		<%-- The image 1 field --%>
		<jsp:include page="/WEB-INF/jsp/common/cmp/modify-img.jsp">
			<jsp:param name="divId" value="newImg1" />
			<jsp:param name="imgCode" value="field.product.image1" />
			<jsp:param name="imgSrc" value="${product.imagePath1}" />
			<jsp:param name="imgPath" value="image1" />
			<jsp:param name="imgAlt" value="${product.name}" />
			<jsp:param name="hiddenRealPath" value="imageRealPath1" />
			<jsp:param name="hiddenPath" value="imagePath1" />
			<jsp:param name="imgCodeModify" value="admin.product.modify.product.image" />
			<jsp:param name="imgCodeNew" value="field.product.image.new" />
			<jsp:param name="formId" value="productModifyForm" />
		</jsp:include>

		<%-- The image 2 field --%>
		<jsp:include page="/WEB-INF/jsp/common/cmp/modify-img.jsp">
			<jsp:param name="divId" value="newImg2" />
			<jsp:param name="imgCode" value="field.product.image2" />
			<jsp:param name="imgSrc" value="${product.imagePath2}" />
			<jsp:param name="imgPath" value="image2" />
			<jsp:param name="imgAlt" value="${product.name}" />
			<jsp:param name="hiddenRealPath" value="imageRealPath2" />
			<jsp:param name="hiddenPath" value="imagePath2" />
			<jsp:param name="imgCodeModify" value="admin.product.modify.product.image" />
			<jsp:param name="imgCodeNew" value="field.product.image.new" />
			<jsp:param name="formId" value="productModifyForm" />
		</jsp:include>

		<%-- The image 3 field --%>
		<jsp:include page="/WEB-INF/jsp/common/cmp/modify-img.jsp">
			<jsp:param name="divId" value="newImg3" />
			<jsp:param name="imgCode" value="field.product.image3" />
			<jsp:param name="imgSrc" value="${product.imagePath3}" />
			<jsp:param name="imgPath" value="image3" />
			<jsp:param name="imgAlt" value="${product.name}" />
			<jsp:param name="hiddenRealPath" value="imageRealPath3" />
			<jsp:param name="hiddenPath" value="imagePath3" />
			<jsp:param name="imgCodeModify" value="admin.product.modify.product.image" />
			<jsp:param name="imgCodeNew" value="field.product.image.new" />
			<jsp:param name="formId" value="productModifyForm" />
		</jsp:include>

		<%-- The image 4 field --%>
		<jsp:include page="/WEB-INF/jsp/common/cmp/modify-img.jsp">
			<jsp:param name="divId" value="newImg4" />
			<jsp:param name="imgCode" value="field.product.image4" />
			<jsp:param name="imgSrc" value="${product.imagePath4}" />
			<jsp:param name="imgPath" value="image4" />
			<jsp:param name="imgAlt" value="${product.name}" />
			<jsp:param name="hiddenRealPath" value="imageRealPath4" />
			<jsp:param name="hiddenPath" value="imagePath4" />
			<jsp:param name="imgCodeModify" value="admin.product.modify.product.image" />
			<jsp:param name="imgCodeNew" value="field.product.image.new" />
			<jsp:param name="formId" value="productModifyForm" />
		</jsp:include>
	</fieldset>

	<fieldset align="center" class="classic">
	 	<legend><spring:theme code="field.product.legend.specific"/></legend>
		<%-- The product type --%>
		<jsp:include page="/WEB-INF/jsp/common/form/form-product-types.jsp">
		    <jsp:param name="mandatory" value="true"/>
		    <jsp:param name="formId" value="productModifyForm"/>
		</jsp:include>
	</fieldset>

	<%-- The submit button --%>
	<div class="row">
		<label>&nbsp;</label>
		<span class="buttonsList">
	         <jsp:include page="/WEB-INF/jsp/common/cmp/button.jsp">
	           <jsp:param name="id" value="submitBt"/>
	           <jsp:param name="label" value="form.submit"/>
	           <jsp:param name="type" value="submit"/>
	         </jsp:include>
	     </span>
	</div>

	<form:hidden path="id"/>

</form:form>

</c:if>


<c:if test="${empty product}">

	<spring:theme code="field.product.no.selected.product"/>

</c:if>